﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Entities;
using Context;
using WCF_ListenMusic.DataContract;
namespace WCF_ListenMusic.Services.Module_Country
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "CountryService" in code, svc and config file together.
    public class CountryService : ICountryService
    {

        Context.Connect_DBDataContext context = new Context.Connect_DBDataContext();
        public List<DataContact_Country> getAllCountry()
        {
            try {
                var q = from c in context.Countries                        
                        select new DataContact_Country() { 
                           CountryID = c.CountryID,
                           CountryName = c.CountryName,                           
                           lst_Category = c.Categories.ToList(),
                        };
                return q.ToList();
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
    }
}
